package com.zhongxi.guoyuan.utils;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Display;
import android.view.Gravity;
import android.view.WindowManager;


/**
 * Created by MacheNike on 2017/3/5.
 */
public class CustomDialog extends Dialog {

    public CustomDialog(Context context, int layout, int style) {
        super(context, style);
        setContentView(layout);
    }

//    public CustomDialog(Context context, int width, int height, int layout, int style) {
//
//        Window window = getWindow();
//        WindowManager.LayoutParams params = window.getAttributes();
//        float getDensity = context.getResources().getDisplayMetrics().density;
//        params.width= (int) (getDensity*width);
//        params.height= (int) (getDensity*height);
//        params.gravity= Gravity.BOTTOM|Gravity.CENTER;
//        window.setAttributes(params);
//    }

    //    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setGravity(Gravity.CENTER);
        WindowManager windowManager = getWindow().getWindowManager();
        Display display = windowManager.getDefaultDisplay();
        WindowManager.LayoutParams attributes = getWindow().getAttributes();
        attributes.width = display.getWidth();
        attributes.height = display.getHeight();
        getWindow().setAttributes(attributes);
    }

//    @Override
//    public void onClick(View v) {
//        dismiss();
//    }
}
